<template>
  <div>
    <van-nav-bar left-text="返回" right-text="确定" @click-left="$emit('close') " @click-right="onConfirm" />
    <van-field v-model="message.user_desc" rows="3" autosize type="textarea" maxlength="50" placeholder="请输入内容" show-word-limit />
  </div>
</template>
<script>
import { updateProfile } from '@/api/user.js'
import { mapState } from 'vuex'
export default {
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      message: this.value
    }
  },
  methods: {
    async onConfirm() {
      this.$toast.loading({ message: '发布中...', forbidClick: true })
      const { data: res } = await updateProfile(this.profile.id, this.message)
      if (res.code === 200) {
        this.$toast.success('修改成功')
        this.$emit('close')
      }
    }
  },
  computed: {
    ...mapState(['profile'])
  }
}
</script>
<style lang="less" scoped>
.van-cell {
  background: unset;
}
/deep/ .van-field__control {
  background: #fff;
}
</style>
